public class myCircleQueue {
    //实现循环队列(通过添加size记录)
    public int front;
    public int rear;
    public int[] elem;
    public int size;
    public myCircleQueue(int k){
        this.elem=new int[k];
        this.size=0;
        this.rear=this.front=0;
    }
    //入栈
    public boolean offer(int val){
        if(isFull(size)){
            return false;
        }
        elem[rear]=val;
        rear++;
        size++;
        return true;
    }
    //出栈
    public boolean poii(){
        int value=0;
        if(empty()){
            return false;
        }else{
            front++;
            size--;
        }
        return true;
    }
    //取队尾元素
    public int Rear(){
        if(empty()){
            return -1;
        }
        int value=elem[rear-1];
        return value;
    }
    //取队头元素
    public int Front(){
        if(empty()){
            return -1;
        }
        int value=elem[front];
        return value;
    }
    //判空
    public boolean empty(){
        return front==rear;
    }
    //判满
    public boolean isFull(int k){
        return size==elem.length;
    }
}
